package com.jia.coupon.controller;


import com.jia.coupon.entity.Coupon;
import com.jia.coupon.service.CouponService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;

/**
 * 优惠券信息(Coupon)表控制层
 *
 * @author makejava
 * @since 2025-07-28 17:36:19
 */
@RestController
@RequestMapping("coupon")
public class CouponController {
    /**
     * 服务对象
     */
    @Resource
    private CouponService couponService;

    @GetMapping("/list")
    public List<Coupon> list() {
        Coupon coupon = new Coupon();
        coupon.setCouponName("满100减10块");
        coupon.setNum(1);
        coupon.setAmount(10.0);
        coupon.setCouponType(0);
        coupon.setUseType(1);
        coupon.setNote("备注");
//        int i = 1 / 0;
        return Collections.singletonList(coupon);
    }

    @PostMapping("/insert")
    public String add(@RequestBody Coupon coupon) {
        couponService.save(coupon);
        return "success";
    }

}

